<!DOCTYPE html>
<!--
See if we can load an AudioBuffer, create an AudioBufferSourceNode, attach the buffer to it, then play it.
-->
<html>
  <head>
    <title>
      audiobuffersource.html
    </title>
    <script src="../../resources/js-test.js"></script>
    <script src="../resources/audit-util.js"></script>
    <script src="../resources/buffer-loader.js"></script>
    <script src="../resources/audio-file-utils.js"></script>
  </head>
  <body>
    <script id="layout-test-code">
      window.onload = init;

      let sampleRate = 44100.0;
      let lengthInSeconds = 2;

      let context = 0;
      let bufferLoader = 0;

      function init() {
        if (!window.testRunner)
          return;

        // Create offline audio context.
        context = new OfflineAudioContext(
            2, sampleRate * lengthInSeconds, sampleRate);

        bufferLoader = new BufferLoader(
            context,
            [
              '../resources/hyper-reality/br-jam-loop.wav',
            ],
            finishedLoading);

        bufferLoader.load();
        testRunner.waitUntilDone();
      }

      function finishedLoading(bufferList) {
        let bufferSource = context.createBufferSource();
        bufferSource.buffer = bufferList[0];

        bufferSource.connect(context.destination);
        bufferSource.start(0);

        context.oncomplete = finishAudioTest;
        context.startRendering();
      }
    </script>
  </body>
</html>
